import time

import allure
import pytest
import requests
import os
basedir=os.path.dirname(__file__)
filepath=os.path.join(basedir,"testCase/profileUpdate.json")
from .data import load_profileUpdatedate,baseurl
@allure.epic("修改用户资料接口")
class TestProfileUpdate:
    def setup_class(self):
        self.session=requests.session()
        self.session.post(f"{baseurl}",data={"username":"test_profileUpdate","password":"111111"})
        print("修改用户资料接口测试开始：", time.strftime("%Y-%m-%d-%H:%M:%S"))
    def teardown_class(self):
        self.session.close()
        print("修改用户资料接口测试结束：", time.strftime("%Y-%m-%d-%H:%M:%S"))
    @pytest.mark.parametrize("testCase,email,phone,password,status_code,msg",load_profileUpdatedate(filepath))
    @allure.title("{testCase}")
    def test_profileUpdate(self,testCase,email,phone,password,status_code,msg):
        self.url=f"{baseurl}/profile/update"
        data={
            "email":email,
            "phone":phone,
            "password":password
        }
        responses=self.session.post(self.url,data=data)
        assert status_code==responses.status_code
        assert msg in responses.text
